<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 给定两个字符串形式的非负整数 `num1` 和`num2` ，计算它们的和并同样以字符串形式返回。
      // 注意：**不能把此字符串转化为数字！！！，**也就是说，不能将  `num1` 和`num2` 转化为数字

      function getNumber(num1, num2) {
        if (num1 === '0') {
          return num2
        }
        if (num2 === '0') {
          return num1
        }
        const n1 = num1.split('').reverse()
        const n2 = num2.split('').reverse()

        let sum1 = 0
        let sum2 = 0
        for (let i = 0; i < n1.length; i++) {
          // console.log(n1[i] * Math.pow(10, i))
          sum1 += n1[i] * Math.pow(10, i)
        }
        for (let j = 0; j < n2.length; j++) {
          sum2 += n2[j] * Math.pow(10, j)
        }
        return sum1 + sum2 + ''
      }
      console.log(getNumber('11', '123'))
      console.log(getNumber('456', '77'))
      console.log(getNumber('0', '0'))
    </script>
  </body>
</html>
